<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <link href="http://www.izhushou.cn/styles/css/global.source.css?13041202" type="text/css" rel="stylesheet"/>
    <script src="http://www.izhushou.cn/styles/js/jquery1.7.1.js"></script>
    <script src="http://www.izhushou.cn/styles/js/scrollbar_jquery.js"></script>
    <script src="http://www.izhushou.cn/styles/js/show.js"></script>
    <script src="http://www.izhushou.cn/styles/js/jquery.cookie.js"></script>
    <title>应用详细页</title>
</head>
<body>
<div id="wrap">
    <div id="bd">

        <div class="item-sya collr">
            <div class="coll">
                <span class="mask_1"></span>
                <img src="<?php $pics = explode('|',$app_info['PIC']); echo $pics[0];?>" alt="" width="102" height="102" class="thumb" />
                <p class="user-state"><span class="<?php if($status && $status!=2 && $status!=5)echo 'btn-sya ';?>btn"><span id="download_status" onClick="window.external.download(<?php echo $app_info['ID'];?>)" class="b"><?php echo $stat;?></span><input id="app_status" type="hidden" value="<?php echo $status;?>"/></span></p>
            </div>
            <div class="colr">
                <h3 class="t"><?php echo $app_info['APP_TITLE'];?><input id="version_id" type="hidden" value="<?php echo $app_info['VERSION_ID'];?>"/><input id="app_id" type="hidden" value="<?php echo $id;?>"/></span></h3>
                <div class="rate-score"><span class="score-star"><em class="star-cur" style="width:<?php echo (intval($score[0])/5)*85;?>px"></em></span><span class="p"><?php if($score[1]) echo '('.$score[1].')';?></span></div>
                <ul class="wx-list-sya">
                    <li class="wx-item f"><span class="nm">版本：</span><?php echo $app_info['BUNDLE_VERSION'];?></li>
                    <li class="wx-item"><span class="nm">大小：</span><?php echo $app_info['APP_SIZE'];?></li>
                    <li class="wx-item <?php if($app_info['APP_PRICE']){echo 'f';}?>"><span class="nm">类别：</span><?php echo $app_info['GENRE'];?></li>
                    <?php if($app_info['APP_PRICE']){?>
                    <li class="wx-item"><span class="nm">原价：</span>￥<del><?php
                    printf('%.2f',$app_info['APP_PRICE']);?></del></li>
                    <?php }?>
                    <li class="wx-item"><span class="nm">更新：</span><?php echo $app_info['UPDATE_TIME'];?></li>
                    <li class="wx-item"><span class="nm">支持：</span><?php echo $app_info['VERS_CONTENT'];?></li>
                </ul>
            </div>
        </div>

        <!--bx-sya-->
        <div class="bx-sya">
            <ul class="wx-list-syb">
                <li class="wx-item select"><a href="#" class="wx"><span class="wxa">详细介绍</span></a><b class="arrow"></b></li>
                <li class="wx-item"> <a href="#" class="wx"><span class="wxa">用户评论</span></a><b class="arrow"></b></li>
            </ul>
            <p class="total">共<?php echo $com_array['total'];?>条评论</p>
            <!--info-->
            <div class="info">
                <div class="hd">
                    <h2 class="h"><?php echo $type_arr[$type]; ?>屏幕截图</h2>
                    <?php if($type == 3){?>
                    <ul class="wx-list-syc">
                        <li class="wx-item iphone"><span style="cursor:pointer" class="wx select">iphone</span></li>
                        <li class="wx-item ipad"><span style="cursor:pointer" class="wx">ipad</span></li>
                    </ul>
                    <?php }?>
                </div>

                <!--scroll-plug-->
                <div class="scroll-plug">
                    <div class="scroll-wrap" id="J_scroll-wrap">
                        <div class="scroll-width">
                            <ul class="scroll-panel p-list-sya" id="J_scroll-panel0">
                                <?php if($img_arr){
                                    foreach($img_arr as $v){
                                    ?>
                                <li class="p-item"><img height="300" alt="" class="thumb" src="<?php if(!strstr($v,'http')){ echo 'http://'.$url_arr[array_rand($url_arr,1)];} echo $v;?>"></li>
                                <?php
                                    }
                            }?>
                            </ul>
                        </div>
                        <div class="scroll-width" style="display:none;">
                            <ul class="scroll-panel p-list-sya" id="J_scroll-panel1">
                                <?php if($imgs['iPad']){
                                    foreach($imgs['iPad'] as $v){
                                    ?>
                                <li class="p-item"><img height="300" alt="" class="thumb" src="<?php if(!strstr($v,'http')){ echo 'http://'.$url_arr[array_rand($url_arr,1)];} echo $v;?>"></li>
                                <?php
                                    }
                            }?>
                            </ul>
                        </div>
                    </div>
                    <div class="scroll-bar-wrap">
                        <div id="J_bar" class="scroll-bar" style="width:92px;left:249px;position:absolute">
                            <div class="scroll-bar-in">
                                <div class="sbinner"></div>
                                <b class="lb"></b>
                                <b class="rb"></b>
                            </div>
                        </div>
                        <b class="sbwl"></b>
                        <b class="sbwr"></b>
                    </div>
                </div>
                <!--/scroll-plug-->

                <!--bx-content-->
                <div class="bx-content">
                    <h3>内容详情：</h3>
                    <p><?php echo $app_info['CONTENT'];?></p>
                </div>
                <!--/bx-content-->
                <?php if($app_info['BODY_CONTENT']){?>
                <br/>
                <!--bx-content2-->
                <div class="bx-content">
                    <h3>版本 <?php echo $app_info['BUNDLE_VERSION'];?> 中的新功能：</h3>
                    <p><?php echo $app_info['BODY_CONTENT'];?></p>
                </div>
                <!--/bx-content2-->
                <?php } ?>
            </div>
            <!--/info-->

            <!--comment-->
            <div class="comment" style="display: none;">
                <div class="to-comment">
                    <input id="page_id" type="hidden" value="" >
                    <input id="pages" type="hidden" value="<?php echo $com_array['pages'];?>" >
                    <a class="btn" href="#"><span class="b btn">我要评论</span></a>
                </div>
                <ul class="comment-list">
                    <?php if($com_arr){
                            foreach($com_arr as $v){?>
                    <li class="comment-item">
                        <div class="comment-title">
                            <p class="title"><strong><?php echo $v['COM_TITLE'];?></strong></p>
                            <div class="rate-score"><span class="score-star"><em style="width:<?php echo (intval($v['RATING'])/5)*85;?>px" class="star-cur"></em></span><span class="p"><?php echo $star_msg[$v['RATING']];?></span></div>
                        </div>
                        <div class="comment-info">评论人：<?php echo $v['USER_NAME'];?>  <?php echo $v['ADD_TIME'];?></div>
                        <p class="comment-content"><?php echo $v['CONTENT'];?></p>
                    </li>
                    <?php }}?>
                </ul>
                <?php if($com_array['pages']>1){?>
                <div class="comment-act">
                    <a onClick="get_list(this);" class="more" href="#com_page">查看更多评论</a><a class="backtotop" href="#">返回顶部↑</a> </div>
                <?php }?>
                <div id="com_page" ></div>
            </div>
            <!--/comment-->
        </div>
        <!--/bx-sya-->

    </div>
</div>
<script type="text/javascript">
function change_status(stat){
    var status_arr = new Array();
    status_arr[0] = "下载";
    status_arr[1] = "等待下载";
    status_arr[2] = "下载中";
    status_arr[3] = "暂停下载";
    status_arr[4] = "下载失败";
    status_arr[5] = "安装";
    status_arr[6] = "更新";
    status_arr[7] = "等待安装";
    status_arr[8] = "安装中";
    status_arr[9] = "安装中";
    status_arr[10] = "安装失败";
    status_arr[11] = "已安装";
    document.getElementById("download_status").innerHTML = status_arr[stat];
    document.getElementById("app_status").value = stat;
    if(stat == 0 || stat == 2 || stat==5){
        document.getElementById("download_status").parentNode.setAttribute("class","btn");
    } else{
        document.getElementById("download_status").parentNode.setAttribute("class","btn-sya btn");
    }
}

function get_status(){
    var sta = document.getElementById("app_status").value;
    window.external.sendinfo(sta);
}

var get_list;
var selectStar;

$(function(){
    $('#page_id').val(2);
    var time,relatedVideos=$('#J_scroll-panel0').scrollbar({scrollWrap:'#J_scroll-wrap',scrollBar:'#J_bar'});
    $(window).resize(function(){
        time && clearTimeout(time);
        time = setTimeout(function(){
            $('#J_scroll-panel0').scrollbar({scrollWrap:'#J_scroll-wrap',scrollBar:'#J_bar'})
        },200)
    });

    var o = $('.wx-list-syc').find('li');
    o.each(function( index ) {
        $(this).click(function(){
            $(this).parent().find('span').removeClass("select");
            $(this).find('span').addClass("select");
            $('.scroll-wrap div').hide();
            $('.scroll-wrap div').eq(index).show();

            var time,relatedVideos=$('#J_scroll-panel'+index).scrollbar({scrollWrap:'#J_scroll-wrap',scrollBar:'#J_bar'});
            time && clearTimeout(time);
            time = setTimeout(function(){
                $('#J_scroll-panel'+index).scrollbar({scrollWrap:'#J_scroll-wrap',scrollBar:'#J_bar'})
            },200);
        })
    });
    var app_id = $('#app_id').val();
    var com_show = $.cookie('com_' + app_id);
    var pan = $('.wx-list-syb').find('li');
    pan.each(function( index ) {
        $(this).click(function(){
            com_sh(index,app_id);
        })
    });

    function com_sh(index,app_id){
        if(index == 1){
            $('.wx-list-syb').find('li').removeClass("select");
            $('.wx-list-syb').find('li').eq(1).addClass("select");
            var date = new Date();
            date.setTime(date.getTime() + (2 * 60 * 1000));
            $.cookie('com_' + app_id, '1', { path: '/', expires: date });
            $('.info').hide();
            $('.comment ').show();
        }else{
            $('.wx-list-syb').find('li').removeClass("select");
            $('.wx-list-syb').find('li').eq(0).addClass("select");
            $.cookie('com_' + app_id, null, { path: '/' });
            $('.info').show();
            $('.comment').hide();
        }
    }
    com_sh(com_show,app_id);

    get_list = function (t){
        var div = document.createElement('div');
        t.parentNode.insertBefore(div,t);
        div.className='comment-loading';
        div.innerHTML='<img src="styles/img/loading.gif"/><span class=\'txt\'>正在加载中.....</span>';
        t.parentNode.removeChild(t);

        var page_id = $('#page_id').val();
        var pages = $('#pages').val();
        app_show.get('/show.php?act=get_list', {
            app_id:$('#app_id').val(),
            page_id:page_id
        }, function (s) {
            var div = $(s);
            var coms = $('.comment-list').html();
            $('.comment-list').html(coms + div.html());

            var next_page = page_id*1+1*1;
            if(next_page<=pages*1){
                $('.comment-act').html('<a onclick="get_list(this);" class="more" href="#com_page">查看更多评论</a><a class="backtotop" href="#">返回顶部↑</a> </div>');
                $('#page_id').val(next_page);
            }else{
                $('.comment-act').html('<a class="backtotop" href="#">返回顶部↑</a> </div>');
                $('#page_id').val(page_id*1);
            }
        }, 'html');
    }

    $('.to-comment').click(function(){
        var tok = $('#token').val();
        app_show.create('app_show.dialog.comment',{data:{tok:tok}}).show();
        app_show.reimg($('.img-yzm'));

        var txt_tit = $('.fl input');

        txt_tit.click(function() {
            if (this.value == '30字以内') {
                this.value = '';
            }
            this.style.color = '#000';
        });

        txt_tit.blur(function() {
            check_input(txt_tit,30,'30字以内',1);
        });
        txt_tit.keyup(function() {
            check_input(txt_tit,30,'30字以内',1);
        });

        var txt_com = $('.form-sya textarea');

        txt_com.click(function() {
            if (this.value == '200字以内') {
                this.value = '';
            }
            this.style.color = '#000';
        });

        txt_com.blur(function() {
            check_input(txt_com,200,'200字以内',1);
        });
        txt_com.keyup(function() {
            check_input(txt_com,200,'200字以内',1);
        });

        var txt_yzm = $('.yzm input');

        $('#rating').val(0);
        /**
         * 活动评价星级动作
         */
        $('.rate-score-list li').mouseover(function () {
            $('.rate-score-list a').removeClass('scored');
            $('.rate-score-sya').find('span').html(star_msg[$(this).index()]);
        });

        /**
         * 活动评价星级动作
         */
        $('.rate-score-list li').mouseleave(function () {
            var sta = $('#rating').val();
            if(sta*1>0){
                $('.rate-score-sya').find('span').html(star_msg[sta*1-1]);
                $('.rate-score-list a').eq(sta*1-1).addClass('scored');
            }else{
                $('.rate-score-sya').find('span').html('');
            }
        });
        $('.form-act span').click(function() {
            var ct = check_input(txt_tit,30,'30字以内',2);
            var cc = check_input(txt_com,200,'200字以内',2);
            var cy = check_input(txt_yzm,4,'',2);
            var url = $('.yzm input').val();
            var rating = $('#rating').val();
            if(rating*1 == 0){
                $('.rate-score-sya').parents('.form-item').addClass('error');
            }else{
                $('.rate-score-sya').parents('.form-item').removeClass('error');
                if(ct&&cc&&cy){
                    var com_title = $.trim($('.fl input').val());
                    var content = $.trim($('.form-sya textarea').val());
                    var yzm = $.trim($('.yzm input').val());
                    app_show.post('/comment.php?act=add', {
                        app_id:$('#app_id').val(),
                        com_title:com_title,
                        content:content,
                        yzm:yzm,
                        rating:rating,
                        token:tok
                    },function (o) {
                        if (o.success == true) {
                            app_show.create('app_show.dialog.alert',{
                                autoClose:true,data:{},ok:function(win) {
                                    win.close();
                                }}).show();

                            app_show.get('/show.php?act=get_list', {
                                app_id:$('#app_id').val(),
                                page_id:1
                            }, function (s) {
                                var div = $(s);
                                $('.comment-list').html(div.html());
                                $('.total').html('共'+$('#page_1').val()+'条评论');
                            }, 'html');
                        }else{
                            if(o.data == 1){
                                app_show.reimg($('.img-yzm'));
                                txt_yzm.parents('.form-item').addClass('error');
                                $('.error-ts').html(o.message);
                                $('.error-ts').show();
                            }else{
                                $(this).parent('a').addClass('disable');
                                var width_warning = 350;
                                if(o.data){
                                    width_warning = o.data;
                                }
                                app_show.create('app_show.dialog.warning',{
                                    data:{wid:width_warning,html:o.message},ok:function(win) {
                                        win.close();
                                    }}).show();
                            }
                        }});

                }
            }
        });
        return false;
    });


    function check_input(txt_com,numb,msg,err) {
        var keyword = txt_com.val();
        keyword = $.trim(keyword.replace(/\s+/g, ''));
        var nnlen = keyword.length;
        if (nnlen == 0 || keyword == msg) {
            if(err>1){
                txt_com.parents('.form-item').addClass('error');
            }
            if(msg){
                txt_com.attr('style', 'color:#C1C0C0');
                txt_com.val(msg);
            }else{
                $('.error-ts').show();
                txt_com.attr('style', 'color:#C1C0C0;width:90px;');
            }
            return false;
        }else if (nnlen > numb) {
            if(err>1){
                txt_com.parents('.form-item').addClass('error');
            }
            txt_com.val(txt_com.val().substr(0, numb));
            return false;
        }else{
            txt_com.parents('.form-item').removeClass('error');
        }
        $('.textarea').attr('style', '');
        if(!msg){
            $('.error-ts').hide();
        }
        return true;
    }
    var star_msg = ['讨厌', '不喜欢', '还可以', '喜欢', '很喜欢', ''];
    var star = 5;

    selectStar = function (t,star_num) {
        t.addClass('scored');
        $('#rating').val(star_num);
        $('.rate-score-sya').find('span').html(star_msg[star_num]);
    }
});
</script>

</body>
</html>